package com.victory.calculator.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.victory.calculator.R;
import com.victory.calculator.activity.ApplyActivity;
import com.victory.calculator.activity.RedemptionActivity;
import com.victory.calculator.activity.SubscriptionActivity;
import com.victory.calculator.entity.ComputingEntity;

import tech.com.commoncore.manager.GlideManager;
import tech.com.commoncore.utils.FastUtil;
import tech.com.commoncore.utils.OnNoDoubleClickListener;

public class ComputingAdapter extends BaseQuickAdapter<ComputingEntity, BaseViewHolder> {



    public ComputingAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(final BaseViewHolder helper, ComputingEntity item) {

        ImageView iv = (ImageView) helper.getView(R.id.img_icon);
        if (item.getIcon() == R.mipmap.tool_icon_shengou){
            GlideManager.loadImg(R.mipmap.tool_icon_shengou, iv, R.mipmap.ic_launcher);
        }else if (item.getIcon() == R.mipmap.tool_icon_rengou){
            GlideManager.loadImg(R.mipmap.tool_icon_rengou, iv, R.mipmap.ic_launcher);
        }else {
            GlideManager.loadImg(R.mipmap.tool_icon_shuhui, iv, R.mipmap.ic_launcher);
        }

        helper.setText(R.id.tv_title,item.getTitle());
        helper.setText(R.id.tv_msg,item.getMsg());

        helper.itemView.setOnClickListener(new OnNoDoubleClickListener() {
            @Override
            public void onNoDoubleClick(View v) {
                if (helper.getPosition() == 0){
                    FastUtil.startActivity(mContext,ApplyActivity.class);
                }else if (helper.getPosition() == 1){
                    FastUtil.startActivity(mContext,SubscriptionActivity.class);
                }else {
                    FastUtil.startActivity(mContext,RedemptionActivity.class);
                }
            }
        });

    }
}
